<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General  License
*/  $cPathBack='';
	if (isset($_GET['cPath'])) $cPathBack = $_GET['cPath'];
	
	$pageBack = $_GET['page'];
	$sortBack = $_GET['sort'];
	$mfrBack = $_GET['manufacturers_id'];
	$filterBack = $_GET['filter_id'];
	
  require('includes/application_top.php');
	require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_COMPARE);
  require(DIR_WS_INCLUDES . 'template_top.php');
?>
<h1><?php echo HEADING_TITLE; ?></h1>
<?php
    $urlStringBack = $_SERVER['QUERY_STRING'];
    if (substr($urlStringBack, 0, 5) == 'manuf') {
?>
    <div class="buttonSet" style="position: absolute; top:10px; right:0px;">
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_DEFAULT, ($mfrBack ? 'manufacturers_id=' . $mfrBack . '&page=' . $pageBack . '&sort=' . $sortBack . '&filter_id=' . $filterBack : ''))); ?></span>
  </div>
<?php
    } else {
?>
    <div class="buttonSet" style="position: absolute; top:10px; right:0px;">
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_DEFAULT, ($cPath ? 'cPath=' . $cPathBack . '&page=' . $pageBack . '&sort=' . $sortBack . '&filter_id=' . $filterBack : ''))); ?></span>
  </div>
<?
    }
?>
<div class="contentContainer">
  <div class="contentText">
<div class="ui-widget infoBoxContainer">
	<div class="ui-widget-header ui-corner-top infoBoxHeading"> 
<table width="100%" border="0" cellspacing="0" cellpadding="2" class="productListingHeader">
	<tr>
		<td align="left"><?php echo TEXT_PRODUCTS_NAME; ?></td>
		<td align="left"><?php echo TEXT_SPECIFICATIONS; ?></td>
  </tr>
</table>
	</div>
  <div class="ui-widget-content ui-corner-bottom productListTable">
<table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingData">             
<?php
	$num = count($_POST['checkgroup']);
	$data = $_POST['checkgroup'];
// MisterSoft cookie compare
if (isset($_COOKIE['compare']))
 {
	$compare = split(',', $_COOKIE['compare']);
	$num = count($compare);
 }
else { $num = 0; $compare = ''; }

	$data = $compare;
	$i = 0;
		while($i < $num) {
			
			$sql_res=tep_db_query("select *,p.products_id pid, p.* from " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS . " p on pd.products_id = p.products_id LEFT JOIN ".TABLE_SPECIALS." ps on ps.products_id = pd.products_id  WHERE p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and pd.products_id = '" . $data[$i]. "'  LIMIT 0,10");

		while($listing=mysql_fetch_array($sql_res))	{

			if (tep_not_null($listing['specials_new_products_price'])) {
				$lc_text = '<span class="productSpecialPrice" style="color:#f00">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
				} else {
				$lc_text = $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']));
			}
			$rating = '';
			if ($listing['products_review_count'] > -1) {
				$rating = sprintf(TEXT_RATED_X_OF_5, $listing['product_rating']);
				$rating .= '<br />';
				$rating .= sprintf(TEXT_TOTAL_REVIEWS, $listing['product_review_count']);
			} else {
				$rating = TEXT_NOT_RATED;
			};
		echo '<tr>
						<td align="center" valign="top">'
						.$listing['products_name'].'<br /><br />'
						.tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)
						.'<br /><br />'.$lc_text . '&nbsp;&nbsp;&nbsp;' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['pid']))
						.'<br /><br />'.$rating.'<br />
						</td>
						<td align="left" valign="top">'.$listing['products_specifications'].'</td>
					</tr>';
		}
		$i++;
	}
?>

</table>
  </div>
	</div>
	</div>
<?php
	$urlStringBack = $_SERVER['QUERY_STRING'];
	if (substr($urlStringBack, 0, 5) == 'manuf') {
?>
	<div class="buttonSet">
	<span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_DEFAULT, ($mfrBack ? 'manufacturers_id=' . $mfrBack . '&page=' . $pageBack . '&sort=' . $sortBack . '&filter_id=' . $filterBack : ''))); ?></span>
  </div>
<?php
	} else {
?>
	<div class="buttonSet">
	<span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_DEFAULT, ($cPath ? 'cPath=' . $cPathBack . '&page=' . $pageBack . '&sort=' . $sortBack . '&filter_id=' . $filterBack : ''))); ?></span>
  </div>
<?
	}
?>
</div>
<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
